import {ACTION_TYPES} from './ActionTypes'
import {bindActionCreators} from 'redux'
import {ResponseError} from '../../../api/ResponseError'

export const errorActions = {
  setState: (state: object) => ({
    type: ACTION_TYPES.ERROR_SET_STATE,
    state,
  }),
  setError: (error: ResponseError) => ({
    type: ACTION_TYPES.ERROR_SET_ERROR,
    error,
  }),
}

export type ErrorActionsType = typeof errorActions

export function bindErrorActions(dispatch: any): any {
  return bindActionCreators(errorActions, dispatch)
}
